package com.dense.kuiniu.floatcabinet.mvp.presenter;

import com.dense.kuiniu.floatcabinet.mvp.contract.AdminContract;
import com.dense.kuiniu.floatcabinet.mvp.manager.bord.Door;
import com.dense.kuiniu.floatcabinet.mvp.model.AdminModel;
import com.dense.kuiniu.floatcabinet.utils.RxUtils;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.mvp.IModel;

import java.util.List;

import javax.inject.Inject;

import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;

/**
 * @author Administrator
 * @date 2020/11/6
 */
public class AdminPresenter extends BasePresenter<IModel, AdminContract.View> {

    @Inject
    AdminModel model;
    @Inject
    RxErrorHandler rxErrorHandler;

    @Inject
    public AdminPresenter(AdminContract.View rootView) {
        super(rootView);
    }

    public void queryDoor() {
        model.query()
                .compose(RxUtils.applySchedulers(mRootView))
                .subscribe(new ErrorHandleSubscriber<List<Door>>(rxErrorHandler) {
                    @Override
                    public void onNext(List<Door> doors) {
                        mRootView.showDoorData(doors);
                    }
                });
    }

} 